package com.wmh.baseservice.merchant.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wmh.baseservice.admin.pojo.AdMenu;
import com.wmh.baseservice.common.mybatisplus.structure.CustomQueryWrapper;
import com.wmh.baseservice.common.utils.returnbody.ReturnBody;
import com.wmh.baseservice.merchant.pojo.MerchantMenu;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import com.wmh.baseservice.merchant.service.MerchantMenuService;

import java.util.List;

/**
 * @author wmh generator
 * @since 2022-01-09
 */
@Api(tags = "商家菜单表")
@RestController
@RequestMapping(value = "merchant/merchantMenu", produces = "text/plain;charset=utf-8")
@RequiresRoles("merchant")
@RequiresPermissions("所有权限")
public class MerchantMenuController {

    @Resource
    private MerchantMenuService merchantMenuService;

    @ApiOperation("所有菜单")
    @PostMapping("allList")
    public String allList() {
        QueryWrapper<MerchantMenu> queryWrapper = new CustomQueryWrapper<MerchantMenu>()
                .select(MerchantMenu.getFields(AdMenu.SORT))
                .orderByDesc(MerchantMenu.SORT);
        List<MerchantMenu> list = merchantMenuService.list(queryWrapper);
        return ReturnBody.success(list);
    }

}
